<?php
/**
 * Created by PhpStorm.
 * User: hongyeah
 * Date: 2015/10/22
 * Time: 23:24
 */

namespace Admin\Controller;


use Think\Controller;

class DoctorsController extends Controller
{
    public function listDoctors(){
        /*$data = array(
            'dot_name'          => 'name',
            'dot_number'       => 'numbe',
            'dot_major'         => 'major',
        );
        $schedule = array(
            'Mon' => 1,
            'Tue' => 2,
            'Wed' => 2,
            'Thu' => 2,
            'Fri' => 2,
            'Sat' => 2,
            'Sun' => 2,
        );
        $dots_model = D('doctors');

        $result = $dots_model->addDots($data,$schedule);
        dump($result);*/
        $this->display();
    }

    public function addMessage(){
        $this->display();
    }

    public function addDoctors(){
        $number = I('post.dot_number');
        $name   = I('post.dot_name');
        $major  = I('post.dot_major');
        $Mon    = I('post.Mon');
        $Tue    = I('post.Tue');
        $Wed    = I('post.Wed');
        $Thu    = I('post.Thu');
        $Fri    = I('post.Fri');
        $Sat    = I('post.Sat');
        $Sun    = I('post.Sun');
        $data   = array(
            'dot_name'          => $name,
            'dot_number'       => $number,
            'dot_major'         => $major,
        );
        $schedule = array(
            'dot_major'         => $major,
            'Mon' => $Mon,
            'Tue' => $Tue,
            'Wed' => $Wed,
            'Thu' => $Thu,
            'Fri' => $Fri,
            'Sat' => $Sat,
            'Sun' => $Sun,
        );
        $dots_model = D('doctors');

        $result = $dots_model->addDots($data,$schedule);

        $this->ajaxReturn($result);
    }
    public function delDoctorsById(){
        $ids = I('ids');

        $this->ajaxReturn(D('Doctors')->delDotsById($ids));

    }

    public function saveDoctors(){
        $number = I('post.dot_number');
        $name   = I('post.dot_name');
        $major  = I('post.dot_major');
        $Mon    = I('post.Mon');
        $Tue    = I('post.Tue');
        $Wed    = I('post.Wed');
        $Thu    = I('post.Thu');
        $Fri    = I('post.Fri');
        $Sat    = I('post.Sat');
        $Sun    = I('post.Sun');
        $data   = array(
            'dot_name'          => $name,
            'dot_number'       => $number,
            'dot_major'         => $major,
        );
        $schedule = array(
            'dot_major'         => $major,
            'Mon' => $Mon,
            'Tue' => $Tue,
            'Wed' => $Wed,
            'Thu' => $Thu,
            'Fri' => $Fri,
            'Sat' => $Sat,
            'Sun' => $Sun,
        );
        $dots_model = D('doctors');

        $result = $dots_model->edtDots($data,$schedule);

        $this->ajaxReturn($result);
    }

    public function getDoctorsList(){
        $search = I('search/s');
        $users_model = D('Doctors');

        try{
            $data = $users_model->getDotsList($search);
            
        }catch (Exception $e){
            $this->ajaxReturn(array('state'=>'0','show'=>0));
        }

        $data->state = 1;

        $this->ajaxReturn($data);
    }
    public function edtMessage(){
        $id = $_GET['id'];
        $result = D('Doctors')->getDotsByID($id);
//        dump($result);
        $this->assign('doctor',$result);
        $this->display();
    }

    public function DoctorsMessage(){
        $id = $_GET['id'];
        $result = D('Doctors')->getDotsByID($id);
//        dump($result);
        $this->assign('doctor',$result);
        $this->display();
    }
}